<div class="problemindexholder" problemindex="B">
 <div class="ttypography">
  <div class="problem-statement">
   <div class="header">
    <div class="title">
     B. Distances to Zero
    </div>
    <div class="time-limit">
     <div class="property-title">
      time limit per test
     </div>
     2 seconds
    </div>
    <div class="memory-limit">
     <div class="property-title">
      memory limit per test
     </div>
     256 megabytes
    </div>
    <div class="input-file">
     <div class="property-title">
      input
     </div>
     standard input
    </div>
    <div class="output-file">
     <div class="property-title">
      output
     </div>
     standard output
    </div>
   </div>
   <div>
    <p>
     You are given the array of integer numbers
     <span class="tex-span">
      <i>
       a
      </i>
      <sub class="lower-index">
       0
      </sub>
      ,
      <i>
       a
      </i>
      <sub class="lower-index">
       1
      </sub>
      , ...,
      <i>
       a
      </i>
      <sub class="lower-index">
       <i>
        n
       </i>
       - 1
      </sub>
     </span>
     . For each element find the distance to the nearest zero (to the element which equals to zero). There is at least one zero element in the given array.
    </p>
   </div>
   <div class="input-specification">
    <div class="section-title">
     Input
    </div>
    <p>
     The first line contains integer
     <span class="tex-span">
      <i>
       n
      </i>
     </span>
     (
     <span class="tex-span">
      1 ≤
      <i>
       n
      </i>
      ≤ 2·10
      <sup class="upper-index">
       5
      </sup>
     </span>
     ) — length of the array
     <span class="tex-span">
      <i>
       a
      </i>
     </span>
     . The second line contains integer elements of the array separated by single spaces (
     <span class="tex-span">
      - 10
      <sup class="upper-index">
       9
      </sup>
      ≤
      <i>
       a
      </i>
      <sub class="lower-index">
       <i>
        i
       </i>
      </sub>
      ≤ 10
      <sup class="upper-index">
       9
      </sup>
     </span>
     ).
    </p>
   </div>
   <div class="output-specification">
    <div class="section-title">
     Output
    </div>
    <p>
     Print the sequence
     <span class="tex-span">
      <i>
       d
      </i>
      <sub class="lower-index">
       0
      </sub>
      ,
      <i>
       d
      </i>
      <sub class="lower-index">
       1
      </sub>
      , ...,
      <i>
       d
      </i>
      <sub class="lower-index">
       <i>
        n
       </i>
       - 1
      </sub>
     </span>
     , where
     <span class="tex-span">
      <i>
       d
      </i>
      <sub class="lower-index">
       <i>
        i
       </i>
      </sub>
     </span>
     is the difference of indices between
     <span class="tex-span">
      <i>
       i
      </i>
     </span>
     and nearest
     <span class="tex-span">
      <i>
       j
      </i>
     </span>
     such that
     <span class="tex-span">
      <i>
       a
      </i>
      <sub class="lower-index">
       <i>
        j
       </i>
      </sub>
      = 0
     </span>
     . It is possible that
     <span class="tex-span">
      <i>
       i
      </i>
      =
      <i>
       j
      </i>
     </span>
     .
    </p>
   </div>
   <div class="sample-tests">
    <div class="section-title">
     Examples
    </div>
    <div class="sample-test">
     <div class="input">
      <div class="title">
       Input
      </div>
      <pre>9<br/>2 1 0 3 0 0 3 2 4<br/></pre>
     </div>
     <div class="output">
      <div class="title">
       Output
      </div>
      <pre>2 1 0 1 0 0 1 2 3 </pre>
     </div>
     <div class="input">
      <div class="title">
       Input
      </div>
      <pre>5<br/>0 1 2 3 4<br/></pre>
     </div>
     <div class="output">
      <div class="title">
       Output
      </div>
      <pre>0 1 2 3 4 </pre>
     </div>
     <div class="input">
      <div class="title">
       Input
      </div>
      <pre>7<br/>5 6 0 1 -2 3 4<br/></pre>
     </div>
     <div class="output">
      <div class="title">
       Output
      </div>
      <pre>2 1 0 1 2 3 4 </pre>
     </div>
    </div>
   </div>
  </div>
 </div>
</div>
